#! /usr/bin/env python
# -*- coding: utf-8 -*-

# *************************************************************
#  Copyright (c) Huoty - All rights reserved
#
#      Author: Huoty <sudohuoty@gmail.com>
#  CreateTime: 2016-12-29 11:39:08
# *************************************************************

import sys
from subprocess import check_output, CalledProcessError


def is_open(filename):
    try:
        output = check_output("lsof {} 2>/dev/null".format(filename), shell=True)
    except CalledProcessError:
        return False
    else:
        return bool(len(output))


# Script starts from here

if __name__ == "__main__":
    for filename in sys.argv[1:]:
        print "{}: {}".format(filename, is_open(filename))
